import { INCREMENTHANDEL, DECREAMENTHANDEL } from "../constant/CountConstant";

const state = {
  count: 0,
};

export const countReducer = (prevDefault = state, action) => {
  const { type, data } = action;

  switch (type) {
    case INCREMENTHANDEL:
      return {
        ...state,
        count: prevDefault.count + data,
      };

    case DECREAMENTHANDEL:
      return {
        ...state,
        count: prevDefault.count - data,
      };

    default:
      break;
  }

  return prevDefault;
};
